package customview.ike.com.customviewproject;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import java.util.ArrayList;
import java.util.List;

import customview.ike.com.customviewproject.Fragment.BaseFragment;
import customview.ike.com.customviewproject.Fragment.FrangmentOne;
import customview.ike.com.customviewproject.Fragment.FrangmentThree;
import customview.ike.com.customviewproject.Fragment.FrangmentTwo;
import customview.ike.com.customviewproject.widget.StickyLayout.StickyLayout;

/**
 *@author:ike
 *@function: 悬浮控件界面
 *@creat time:15:16 2017/11/30
 **/

public class StickyLayoutActivity extends AppCompatActivity {
    private String Tag="StickyLayoutActivity";
    private StickyLayout sticky_layout;
    private List<BaseFragment> fragmentList=new ArrayList<>();
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sticky);
        sticky_layout= (StickyLayout) findViewById(R.id.sticky_layout);
        initData();
    }

    private void initData() {
        fragmentList.add(new FrangmentOne());
        fragmentList.add(new FrangmentTwo());
        fragmentList.add(new FrangmentThree());
        if (getSupportFragmentManager()==null){
            Log.e(Tag,"getSupportFragmentManager()==null");
        }
        sticky_layout.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));
    }

    class MyPagerAdapter extends FragmentPagerAdapter{

        public MyPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            return fragmentList.get(position);
        }

        @Override
        public int getCount() {
            return 3;
        }
    }
}
